package com.lwl.office.dcconverter.element;

import lombok.Data;

/**
 * 超链接
 */
@Data
public class DCLinkRun extends DCRun{
    private String href;
    @Override
    public String getText() {
        StringBuilder stb = new StringBuilder();
        for (AbsDCElement child : getChildren()) {
            stb.append(((DCRun)child).getText());
        }
        return stb.toString();
    }

    /**
     * <a href="http://localhost:8080" target="_blank" title="本地连接">超链接</a></span>
     * @return
     */
    @Override
    public String toHtml() {
        StringBuilder stb = new StringBuilder();
        stb.append("<a href=\"").append(href).append("\"");
        for (AbsDCElement child : getChildren()) {
            stb.append(child.toHtml());
        }
        stb.append("</a>");
        return stb.toString();
    }
}
